<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="https://v3.bootcss.com/favicon.ico">
<title>注册</title>
<link href="/css/bootstrap/bootstrap.min.css" rel="stylesheet">
<link href="/css/page/blog.css" rel="stylesheet">

</head>

<body>

	<#include "/nav.ftl"/>

	<div class="container">
		<div class="row" style="padding-top: 20px">
			<form class="form-horizontal" id="form_password_modify">
				
				<div class="form-group">
					<label for="ipt_old_password" class="col-sm-2 control-label">旧密码</label>
					<div class="col-sm-10">
						<input type="password" maxlength="20" name="oldPassword" class="form-control notEmpty" id="ipt_old_password" placeholder="旧密码">
					</div>
				</div>
				<div class="form-group">
					<label for="ipt_new_password" class="col-sm-2 control-label">新密码</label>
					<div class="col-sm-10">
						<input type="password" maxlength="20" name="newPassword" class="form-control notEmpty" id="ipt_new_password" placeholder="新密码">
					</div>
				</div>
				<div class="form-group">
					<label for="ipt_confirm_new_password" class="col-sm-2 control-label">确认密码</label>
					<div class="col-sm-10">
						<input type="password" maxlength="20" class="form-control notEmpty" id="ipt_confirm_new_password" placeholder="确认密码">
					</div>
				</div>
				
				<div class="form-group">
					<div class="col-sm-offset-2 col-sm-10">
						<button type="button" onclick="save()" class="btn btn-default">保存</button>
					</div>
				</div>
			</form>
		</div>
		<!-- /.row -->

	</div>
	<!-- /.container -->
	<#include "/foot.ftl"/>
	<script src="/js/jquery/jquery.min.js"></script>
	<script src="/js/bootstrap/bootstrap.min.js"></script>
	<script type="text/javascript" src="/js/bootstrap/plugins/bootbox.js"></script>
	<script type="text/javascript" src="/js/common/common.js"></script>
	<script type="text/javascript" src="/js/common/myValidation.js"></script>
	<script type="text/javascript">
		function save(){
			var validResult = myValidation.commonValid("form_password_modify", {
				showInfo : function(ele, mes) {
					bootbox.alert(mes,function(){
						$(ele).focus();
					});
					
				}
			});
			if (!validResult) {
				return;
			}
			var password = $("#ipt_new_password").val();
			var confirmPassword = $("#ipt_confirm_new_password").val();
			if(password !== confirmPassword){
				bootbox.alert("两次输入的密码需要一致");
				return;
			}
			
			$.post("/user/password/modify", $("#form_password_modify").serialize(), function(result){
				if(result.code == 200){
					bootbox.alert("修改成功,请重新登录", function(){
						location.href = "/login";
					})
				}else{
					bootbox.alert(result.mes);
				}
			})
			
		}		
		
	</script>
</body>

</html>